
version 8.0 
log using pres_runoff_xtpcse.log, replace
 #delimit ;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      pres_runoff_xtpcse.do                           *;
*       Date:           5/18/05                                          *;
*       Author:         MRG                                             *;
*       Purpose:        Do-file to replicate results for AJPS version   *;
*                       of presidential candidates paper where          *;
*                       dependent variable is presidential candidates.  *;
*                       Tables 2 and 3. Use XTPCSE instead.             *;
*       Input File:     presidential_new.dta                            *;
*       Output File:    pres_runoff_xtpcse.log                          *;
*       Data Output:    None                                            *;
*       Previous file:                                                  *;
*       Machine:        Home                                            *;
*     ****************************************************************  *;
*     ****************************************************************  *;

set mem 10m;
set matsize 150;

use c:\ajps\presidential_new.dta;

*     ****************************************************************  *;
*                           Summary Statistics                          *;
*     ****************************************************************  *;

sum;

*     ****************************************************************  *;
*                    Relabel and Define Variables                       *;
*     ****************************************************************  *;

label var country  "countryname";
label var newdem "first election as new democracy";
label var countrynumber "countrynumber";
label var year "year";
label var regime "regime as of 31 December of given year 0=democracy 1=dictatorship";
label var regime_leg "regime type at time of legislative election 0 = democracy 1=dictatorship";
label var legelec "legislative election";
label var preselec "presidential election";
label var eighties "election in 1980s closest to 1985";
label var old "elections in countries that did not transition to democracy in 1990s";
label var nineties "elections in 1990s closest to 1995";
label var proximity1 "proximity - continuous";
label var proximity2 "proximity - dichotomous";
label var enpp "parliamentary parties - uncorrected";
label var enpp1 "parliamentary parties - corrected";
label var enep "electoral parties - uncorrected";
label var enep1 "electoral parties - corrected";
label var enpres "effective number of presidential candidates";
label var seats "assembly size";
label var districts "number of electoral districts";
label var avemag "average district magnitude";
label var medmag "median district magnitude";
label var upperseats "number of uppertier seats";
label var uppertier "percentage of uppertier seats";
label var eneg "effective number of ethnic groups  fearon";

describe;

sum preselec if pres_plurality==1;
sum preselec if pres_majority==1;
sum preselec if pres_qualmaj==1;
sum preselec if pres_stv==1;
sum preselec if pres_college==1;
sum preselec if pres_runoff==1;

*     ****************************************************************  *;
*       Would like to drop certain countries that do not fit.           *;
*       1. Drop Kiribati - not free entry of candidates                 *;
*       2. Drop elections that ultimately use an electoral college      *;
*       to determine who wins.  This means dropping Argentina 1946,     *;
*       1958, 1963, 1983, 1989, United States (all presidential         *;
*       elections), Finland 1950, 1956, 1962, 1968, 1978, 1982.         *;
*       3. Drop Ireland (all presidential elections) and Sri Lanka      *;
*       1994, 1999 since they use STV.                                  *;
*     ****************************************************************  *;

drop if countrynumber==163;
drop if countrynumber==65;
drop if countrynumber==113;
drop if countrynumber==96;
drop if countrynumber==66 & year==1946;
drop if countrynumber==66 & year==1958;
drop if countrynumber==66 & year==1963;
drop if countrynumber==66 & year==1983;
drop if countrynumber==66 & year==1989;
drop if countrynumber==106 & year==1950;
drop if countrynumber==106 & year==1956;
drop if countrynumber==106 & year==1962;
drop if countrynumber==106 & year==1968;
drop if countrynumber==106 & year==1978;
drop if countrynumber==106 & year==1982;

sum;

sum countrynumber if enpres>0 & enpres<200 & eneg>0 & eneg<200; 

sum countrynumber if enpres>0 & eneg>0 & eneg<300 & enpres<200 & pres_runoff==1;

sum countrynumber if enpres>0 & eneg>0 & eneg<300 & enpres<200 & pres_plurality==1;

sum enpres if enpres>0 & enpres<200 & eneg>0 & eneg<200;

sum eneg if enpres>0 & enpres<200 & eneg>0 & eneg<200;

*     ****************************************************************  *;
*       214 presidential elections left. 135 runoff, 79 plurality       *;
*       53 countries                                                    *;
*     ****************************************************************  *;

sum enpres if eighties==1;

sum enpres if nineties==1;

*     ****************************************************************  *;
*       21 countries had presidential elections in the 1980s.           *;
*       56 countries had presidential elections in the 1990s.           *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Let's see what the differences are between the cox data for     *;
*       1980s and the data that I collected.                            *;
*     ****************************************************************  *;

correlate enpres_cox enpres;

correlate eneth_cox eneg;

*     ****************************************************************  *;
*           The correlations are actually quite high i.e. 95-99%        *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*                   Create variables ready for regressions              *;
*     ****************************************************************  *;

gen eneg_runoff = eneg*pres_runoff;   
        
*     ****************************************************************  *;
*       There were two elections in Argentina in 1973.  Need to remove  *;
*       one of them.  This leaves 213 elections, 134 runoff, 79         *;
*       plurality, 53 countries.                                        *;
*     ****************************************************************  *;

drop if countrynumber==66& year==1973 & enpres>3;       

tsset countrynumber year, yearly;

*     ****************************************************************  *;
*       xtpcse no lag                                                   *;
*     ****************************************************************  *;

xtpcse enpres eneg pres_runoff  eneg_runoff, pairwise; 

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;

*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.08 (0.08).            *;
*       Effect of eneg in runoff systems is 0.34 (0.07).                *;
*     ****************************************************************  *;


*     ****************************************************************  *;
*       xtpcse no lag, established democracies                          *;
*     ****************************************************************  *;

xtpcse enpres eneg pres_runoff  eneg_runoff if old==1, pairwise; 

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;

*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.06 (0.12).            *;
*       Effect of eneg in runoff systems is 0.60 (0.14).                *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*                   Create the lagged dependent variable.               *;
*     ****************************************************************  *;

tsset countrynumber year, yearly;

sort countrynumber;

by countrynumber: gen enpres_lag=enpres[_n-1];

replace enpres_lag=. if newdem==1;

sum enpres_lag, detail;

*     ****************************************************************  *;
*                           xtpcse with a lag                           *;
*     ****************************************************************  *;

xtpcse enpres eneg pres_runoff  eneg_runoff enpres_lag, pairwise ;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;

*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.14 (0.09).            *;
*       Effect of eneg in runoff systems is 0.20 (0.13).                *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*                xtpcse with a lag, established democracies             *;
*     ****************************************************************  *;

xtpcse enpres eneg pres_runoff  eneg_runoff enpres_lag if old==1,pairwise;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;

*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.08 (0.14).            *;
*       Effect of eneg in runoff systems is 0.55 (0.16).                *;
*     ****************************************************************  *;


*     ****************************************************************  *;
*           xtpcse, lag, presidential regimes                           *;
*     ****************************************************************  *;

xtpcse enpres eneg pres_runoff  eneg_runoff enpres_lag if institution==3, pairwise;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];

scalar conb=b1+b3*1;
display conb;

scalar conse=sqrt(varb1+varb3*1^2+2*covb1b3*1);
display conse;

scalar t=conb/conse;
display t;

*     ****************************************************************  *;
*       Effect of eneg in plurality systems is -0.13 (0.10).            *;
*       Effect of eneg in runoff systems is 0.49 (0.17).                *;
*     ****************************************************************  *;



*     ****************************************************************  *;
*     ****************************************************************  *;
*                                   THE END                             *;
*     ****************************************************************  *;
*     ****************************************************************  *;



exit;
